package com.org.api.admin.entity.po;

import com.org.api.admin.service.CmsUserBaseService;
import com.org.api.admin.service.CmsUserMobileBannerService;
import com.org.api.admin.service.CmsUserMobileGraphicNavigationService;
import com.org.api.admin.service.CmsUserMobileNavigationService;
import com.org.platform.support.conponents.SpringApplicationContextAware;

/**
 * @Description
 * @auther dh
 * @date 2022/3/2 10:15
 */
public enum CmsUserModuleEnum {

	Navigation("1", CmsUserMobileNavigationService.class),
	Banner("2", CmsUserMobileBannerService.class),
	GraphicNavigation("3", CmsUserMobileGraphicNavigationService.class);

	private String moduleType;

	private Class aClass;


	CmsUserModuleEnum(String moduleType, Class aClass) {
		this.moduleType = moduleType;
		this.aClass = aClass;
	}

	public static CmsUserBaseService getServiceClass(String moduleType) {
		CmsUserModuleEnum[] cmsUserModuleEnums = CmsUserModuleEnum.values();
		for (int i = 0; i < cmsUserModuleEnums.length; i++) {
			if (null != moduleType && cmsUserModuleEnums[i].getModuleType().equals(moduleType)) {
				Class serviceClazz = cmsUserModuleEnums[i].getaClass();
				return (CmsUserBaseService) SpringApplicationContextAware.getApplicationContext().getBean(serviceClazz);
			}
		}
		return SpringApplicationContextAware.getApplicationContext().getBean(CmsUserMobileNavigationService.class);
	}

	public String getModuleType() {
		return moduleType;
	}

	public void setModuleType(String moduleType) {
		this.moduleType = moduleType;
	}

	public Class getaClass() {
		return aClass;
	}

	public void setaClass(Class aClass) {
		this.aClass = aClass;
	}
}
